/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.designpatterns.structural.adapter;

/**
 *
 * @author bassoncj
 */
public class TemperatureObjectReporter implements TemperatureInfo{
    CelciusReporter celciusReporter;
    public TemperatureObjectReporter( ) {
        celciusReporter = new CelciusReporter( );
    }

    @Override
    public double getTemperatureInC( ){
        return celciusReporter.getTemperature( );
    }

    @Override
    public double getTemperatureInF( ){
        return ctof(celciusReporter.getTemperature( )) ;
    }

    @Override
    public void setTemperatureInC(double temperatureInC){
      celciusReporter.setTemperature(temperatureInC);
    }

    @Override
    public void setTemperatureInF(double temperatureInF) {
        celciusReporter.setTemperature(ctof(temperatureInF)) ;
    }
    
    private double fToC( double f) {
        return ((f - 32) * 5 / 9);
    }
    
    private double ctof( double c ){
        return ( ( c * 9 / 5) + 32) ;
    }
}
